function [ C ] = mycross(A,B)
%mycross Performs cross product
%   Example of simple input testing and error handling. 

%Check for correct number of input arguments. 
%Note that 'nargin' exists in any function. 
if nargin~=2
   error('You need two inputs! This is a cross product!') 
end

%Check that vectors are the correct length
if (length(A)~=3)||(length(B)~=3)
error('Vectors need to be length 3!') 
end

%Everything OK, proceed with function .....


%Do math
C(1)=A(2)*B(3)-A(3)*B(2);
C(2)=-(A(1)*B(3)-A(3)*B(1));
C(3)=A(1)*B(2)-A(2)*B(1);

end

